package midalgorithms.sortandsearch;

public class _08SearchMatrix {
    public static boolean searchMatrix(int[][] matrix, int target) {
        int row = 0,col = matrix[0].length-1;
        while (row < matrix.length && col >= 0){
            if (target < matrix[row][col]){
                col--;

            }else if (target > matrix[row][col]){
                row++;

            }else {
                return true;
            }
        }
        return false;
    }
}
